package pattern.observer;

import java.util.ArrayList;
import java.util.List;

public class Leader implements Subject {

	private List<Observer> mObservers = new ArrayList<>();

	@Override
	public void register(Observer observer) {
		if (observer != null && !mObservers.contains(observer)) {
			mObservers.add(observer);
		}
	}

	@Override
	public void unRegister(Observer observer) {
		if (observer != null) {
			mObservers.remove(observer);
		}
	}

	@Override
	public void notifyObservers() {
		for (Observer observer : mObservers) {
			observer.update();
		}
	}
}
